/*
 * $Id: MutexLock.h,v 1.2 2005-05-02 11:14:47 bacon Exp $
 */

#ifndef _XPP_BAS_MUTEXLOCK_CLASS_
#define _XPP_BAS_MUTEXLOCK_CLASS_

#include <xpp/bas/Mutex.h>
#include <xpp/Uncopyable.h>

namespace xpp
{
	namespace bas
	{

		class MutexLock: public Uncopyable
		{
		public:
			MutexLock (Mutex* mtx): mutex (mtx)
			{
				if (mutex->lock() == -1) XPP_THROW (MutexException);
			}
			~MutexLock ()
			{
				if (mutex->unlock() == -1) XPP_THROW (MutexException);
			}

		protected:
			Mutex* mutex;
		};

	}
}

#endif
